-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTime Conversion.c
50 lines (49 loc) · 1.31 KB
/
Time Conversion.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @Repository HackerRank Soulutions
* @file Time Conversion
* @author Abdelrahman Ahmed Moussa ([email protected])
* @copyright Copyright (c) 2024
*
*/
/*------------------------------------------------------------------------------*/
/* */
/* I didn't used any functions from <string.h> */
/* */
/*------------------------------------------------------------------------------*/
char* timeConversion(char* s)
{
static char localstr[20]; /*!< 00:00:00 ==> 8 char and null ==> 8+1=9*/
int i=0,num=0;
if (s[8]=='A')
{
if (s[0]=='1'&&s[1]=='2')
{
localstr[0]='0';
localstr[1]='0';
}
else
{
localstr[0]=s[0];
localstr[1]=s[1];
}
}
else if (s[8]=='P')
{
if (s[0]=='1'&&s[1]=='2')
{
localstr[0]=s[0];
localstr[1]=s[1];
}
else
{
localstr[0]=s[0]+1; //((s[0]-'0')+1)+'0';
localstr[1]=s[1]+2;
}
}
for (i=2; i<=7;i++)
{
localstr[i]=s[i];
}
localstr[i]='\0';
return localstr;
}